#pragma once

namespace DirectUI
{
	class CUIGdiplusRender
		: public CUINoAggregateObjectImplHelper<IUIRender, CUIGdiplusRender, IUIRender>
		// IUIRender
	{
		DECLARE_CLASS(CUIGdiplusRender, GdiplusRender)
	public:
		class CUIImageObjectCache
		{
		public:
			CUIImageObjectCache();
			~CUIImageObjectCache();

			std::tr1::shared_ptr<Gdiplus::Bitmap> GetImage(IUIImageSource* lpImageSource);

		private:
			std::map<CString, std::tr1::shared_ptr<Gdiplus::Bitmap>>	m_mapImages;
		};
	public:
		CUIGdiplusRender(void);
		virtual ~CUIGdiplusRender(void);

		virtual void FillRect( void* hDevice, RECT rectDest, UICOLOR color );

		virtual void DrawText( void* hDevice, LPCTSTR lpszText, RECT rcDest, IUIFont* lpFont, IUIStringFormat* lpFormat, UICOLOR color );

		virtual void DrawImage( void* hDevice, IUIImageSource* lpImageSource, RECT rectDest );

		virtual SIZE GetImageSize( IUIImageSource* lpImageSource );

	private:
		CImage					m_ImgInit;
		CUIImageObjectCache		m_ImageObjCache;
	};
}
